<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api'
] ,function ($api){
    $api->get('version', function (){
        return response('this is version v1');
    });

    $api->group([
        'middleware' => 'api.throttle',
        'limit' => 1,
        'expires'=>1
    ], function ($api){
        $api->post('verifyCode', 'SmsController@verifyCode')->name('api.sms.verifyCode');
    });

    $api->post('getToken', 'SmsController@getToken')->name('api.sms.getToken');


    $api->group(['middleware' => 'api.auth'], function ($api){
        $api->post('test', 'SmsController@test')->name('api.sms.test');
    });

});

$api->version('v2', function ($api){
    $api->get('version', function (){
        return response('this is version v2');
    });
});